//
//  MoreViewController.m
//  upnpxdemo
//
//  Created by haiyong on 13-8-25.
//  Copyright (c) 2013年 Bruno Keymolen. All rights reserved.
//

#import "MoreViewController.h"
#import "AboutViewController.h"
#import "AppRecommandViewController.h"
#import "ServerChooseViewController.h"
#import "SurroundViewController.h"
#import "uSurroundViewController.h"

@interface MoreViewController ()
@property (assign) IBOutlet UILabel * titleLabel;

@end

@implementation MoreViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navigation methods
-(NSString *)navigationBarTitle
{
    return NSLocalizedString(@"MORE_TITLE",@"");
}

#pragma mark -
#pragma mark UITableView Delegate & Datasource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 60;
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
    }
    else
    {
        for(UIView * subview in [cell.contentView subviews])
        {
            [subview removeFromSuperview];
        }
    }

    // Configure the cell.
    
    UIImage * image = nil;
    UILabel * label = [[UILabel alloc] init];
//    if(indexPath.row == 0)
//    {
//        image = [UIImage imageNamed:@"recommend.png"];
//        label.text = NSLocalizedString(@"APPRECOMMEND",@"");
//    }
    if(indexPath.row == 0)
    {
        image = [UIImage imageNamed:@"about.png"];
        label.text = NSLocalizedString(@"ABOUT",@"");
    }
    else if(indexPath.row == 1)
    {
        image = [UIImage imageNamed:@"topAnimation_wifi"];
        label.text = @"WIS Demo";
    }
    else if(indexPath.row == 2)
    {
        image = [UIImage imageNamed:@"topAnimation_device"];
        label.text = @"Surrounder Demo";
    }
    else if(indexPath.row == 3)
    {
        image = [UIImage imageNamed:@"topAnimation_device"];
        label.text = @"multiroom Demo";
    }
    
    UIImageView * imageview = [[UIImageView alloc] initWithImage:image];
    [cell.contentView addSubview:imageview];
    [imageview setFrame:CGRectMake(10, 10, 40, 40)];
    
    label.backgroundColor = [UIColor clearColor];
    label.frame = CGRectMake(60, 10, 200, 40);
    [cell.contentView addSubview:label];
    
    UIImageView * rightImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"rightarrow1.png"]];
    rightImage.frame = CGRectMake(tableView.frame.size.width-40, 20, 10, 20);
    [cell.contentView addSubview:rightImage];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:[tableView indexPathForSelectedRow] animated:YES];
    
//    if(indexPath.row == 0)
//    {
//        AppRecommandViewController * controller = [[AppRecommandViewController alloc] initWithNibName:@"AppRecommandViewController" bundle:nil];
//        [self.navigationController pushViewController:controller animated:YES];
//        [controller release];
//    }
    if(indexPath.row == 0)
    {
        AboutViewController * controller = [[AboutViewController alloc] initWithNibName:@"AboutViewController" bundle:nil];
        [self.navigationController pushViewController:controller animated:YES];
    }
    else if(indexPath.row == 1)
    {//WIS Demo
        ServerChooseViewController * controller = [[ServerChooseViewController alloc] initWithNibName:@"ServerChooseViewController" bundle:nil];
        [self.navigationController pushViewController:controller animated:YES];
    }
    else if(indexPath.row == 2)
    {
        SurroundViewController * controller = [[SurroundViewController alloc] initWithNibName:@"SurroundViewController" bundle:nil];
        [self.navigationController pushViewController:controller animated:YES];
    }
    else if(indexPath.row == 3)
    {
        uSurroundViewController * controller = [[uSurroundViewController alloc] initWithNibName:@"uSurroundViewController" bundle:nil];
        [self.navigationController pushViewController:controller animated:YES];
    }
}

@end
